#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "Videolabel.h"

typedef enum
{
    Opened,
    Closed
}DeviceState;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

    //video mat
    cv::VideoCapture capture;
    cv::Mat frame;
    QTimer *videoTimer = new QTimer(this);
    DeviceState videoDS = Closed;

    int pictureCount;
    double camera_f;//camera calibrated focus length(pixel)
    double camera_h;//camera placed height(mm)

private:
    Ui::MainWindow *ui;

public:
    void showVideo();
    void videoOption();//press show video button
    double calBallDiameter(double d);//d is ball diameter in pixel in the picture

private slots:
    void on_camOpenButton_clicked();
    void on_saveImagepushButton_clicked();
    void on_startCalculatepushButton_clicked();
    void on_cameraFocuslineEdit_editingFinished();
    void on_cameraHeightlineEdit_editingFinished();
};

#endif // MAINWINDOW_H
